import {contextBridge, ipcRenderer} from "electron";

let current = localStorage.getItem('current-win')

ipcRenderer.on('currentWindow', (_, cWin) => {
    current = cWin
    localStorage.setItem('current-win', current)
})

contextBridge.exposeInMainWorld('win', {
    operation: function (type, ...args) {
        ipcRenderer.send('win', current, type, ...args)
    }
})

contextBridge.exposeInMainWorld('tools', {
    ipcSend: function (mes, ...args) {
        ipcRenderer.send(mes, ...args)
    },
    ipcInvoke: function (mes, ...args) {
        return ipcRenderer.invoke(mes, ...args)
    }
})
